/*
Kakine
ActionScript Framework
Copyright © 2011, PUNY, LLC.

This file is part of KAKINE.

KAKINE is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

KAKINE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KAKINE.  If not, see <http://www.gnu.org/licenses/>.
*/ 
package com.puny.ball.views.obstacles
{
	import com.puny.ball.utils.Vector2D;
	
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.display.Shape;
	import flash.events.Event;

	public class Obstacle extends MovieClip
	{
		private var _checkers:Array;
		private const _newPos:Vector2D =new Vector2D();
		private const _mirroredPos:Vector2D = new Vector2D();
		private const _hitPos:Vector2D = new Vector2D();
		private var _pos:Number;
		private var _shape:Shape;
		private var _container:DisplayObjectContainer;
		private var _debug:Boolean = false;
		public function Obstacle()
		{
			_shape = new Shape();
			addEventListener(Event.ADDED_TO_STAGE, addedStageHandler);
			addEventListener(Event.REMOVED_FROM_STAGE, removedStageHandler);
			super();
		}

		protected function addedStageHandler(event:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, addedStageHandler);
			_container = parent;
			parent.addChild(_shape);
		}
		
		public function set debug(value:Boolean):void {
			_debug = value;
		}
		
		protected function drawShape():void {}
		
		protected function drawDebugShape():void {
			if (_debug) {
				drawShape();
			}
		}
		
		protected function removedStageHandler(event:Event):void {
			_container.removeChild(_shape);
		}
		
		protected function get container():DisplayObjectContainer {
			return _container;
		}
		
		protected function get shape():Shape {
			return _shape;
		}
		
		protected function get checkers():Array {
			return _checkers;
		}
		
		protected function set checkers(arr:Array):void {
			_checkers = arr;
		}
		
		public function get newPos():Vector2D {
			return _newPos;
		}
		
		public function set newPos(value:Vector2D):void {
			_newPos.x = value.x;
			_newPos.y = value.y;
		}
		
		public function get mirroredPos():Vector2D {
			return _mirroredPos;
		}
		
		public function set mirroredPos(value:Vector2D):void {
			_mirroredPos.x = value.x;
			_mirroredPos.y = value.y;
		}
		
		public function get hitPos():Vector2D {
			return _hitPos;
		}
		
		public function set hitPos(value:Vector2D):void {
			_hitPos.x = value.x;
			_hitPos.y = value.y;
		}
		
		public function get pos():Number {
			return _pos;
		}
		
		public function set pos(value:Number):void {
			_pos = value;
		}
		public function collision(org:Vector2D,dir:Vector2D):Boolean {
			return false;
		}
	}
}